/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Precentacion.java
 *
 * Created on 25/06/2011, 10:43:57 AM
 */

package Vistas;

import Beans.Ciudad;
import Beans.Cliente;
import Beans.Contacto;
import Beans.Pais;
import Beans.Proveedor;
import Beans.Provincia;
import Beans.Ubicacion;
import Controladores.MUbicacion;
import Controladores.Mcliente;
import Controladores.Mproveedor;
import Imagenes.CtrlImagen;
import Vistas.Menu.Menu;
import com.birosoft.liquid.LiquidLookAndFeel;
import java.awt.Image;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.locks.Condition;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;


/**
 *
 * @author Usuario
 */
public class VistaProveedor extends javax.swing.JFrame {

    
 

    /** Creates new form Precentacion */
    int fila;
    boolean estado = false;
    boolean condicion = false;
    Mproveedor Mp = new Mproveedor();
    MUbicacion Mu = new MUbicacion();
    Mcliente Mc = new Mcliente();
    String nits="vacio";
    Contacto co =new Contacto();
    DefaultTableModel modeloTabla = new DefaultTableModel();
    Proveedor p = new Proveedor();
    Proveedor prov = new Proveedor();
    Vector<Proveedor> vp = new Vector<Proveedor>();

      
    public VistaProveedor() {
        initComponents();
    }

    public VistaProveedor(Mproveedor Mp, Mcliente Mc,MUbicacion Mu){
        initComponents();
        
        this.setResizable(false);
        this.DesactivarCampos();
        this.Mp=Mp;
        this.Mu=Mu;
        this.Mc=Mc;
        this.setResizable(false);
        this.jComboBox2.setVisible(false);
        this.jLabel25.setVisible(false);
        this.tablaprincipal(); //llenar la tabla
        this.MostrarJCBpais(); //JCOMOBOX DEL PAIS

    }

    public Contacto Obtenercontacto(Contacto c){
        this.co=c;
        return co;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new CtrlImagen("/Imagenes/a1.jpg");
        jPanelTransparente3 = new Imagenes.JPanelTransparente();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanelTransparente4 = new Imagenes.JPanelTransparente();
        jPanel2 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jTxtNombreRep = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jTxtTelefonoRep = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jTxtCelularRep = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jTxtDirRep = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTxaObs = new javax.swing.JTextArea();
        jBtnLimpiar = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel22 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jTxtFax = new javax.swing.JTextField();
        jTxtMail = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jTxtDireccion = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jCbxProvincia = new javax.swing.JComboBox();
        jCbxPais = new javax.swing.JComboBox();
        jTxtTelefonoPr = new javax.swing.JTextField();
        jLblCodigo = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jTxtNombrePr = new javax.swing.JTextField();
        jTnit = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jTxtWeb = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jCBCiudad = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel25 = new javax.swing.JLabel();
        jPanelTransparente5 = new Imagenes.JPanelTransparente();
        jBSalir1 = new javax.swing.JButton();
        jBActualizar = new javax.swing.JButton();
        jBModificar = new javax.swing.JButton();
        jBEliminar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        JBuscar = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Interfaz Control de Proveedor");
        setBackground(new java.awt.Color(255, 255, 255));

        jPanelTransparente3.setBackground(new java.awt.Color(255, 255, 255));

        jTable1.setModel(modeloTabla);
        jTable1.setToolTipText("Clic para seleccionar");
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS DEL CONTACTO:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("Nombres:");

        jTxtNombreRep.setEditable(false);
        jTxtNombreRep.setToolTipText("Nombre del Contacto");
        jTxtNombreRep.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTxtNombreRepActionPerformed(evt);
            }
        });
        jTxtNombreRep.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtNombreRepKeyPressed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("Teléfono:");

        jTxtTelefonoRep.setEditable(false);
        jTxtTelefonoRep.setToolTipText("Telefono del Contacto");
        jTxtTelefonoRep.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtTelefonoRepKeyPressed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel14.setForeground(new java.awt.Color(255, 255, 255));
        jLabel14.setText("Celularl:");

        jTxtCelularRep.setEditable(false);
        jTxtCelularRep.setToolTipText("Celular del Contacto");
        jTxtCelularRep.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtCelularRepKeyPressed(evt);
            }
        });

        jLabel24.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel24.setForeground(new java.awt.Color(255, 255, 255));
        jLabel24.setText("Direccion:");

        jTxtDirRep.setEditable(false);
        jTxtDirRep.setToolTipText("Celular del Contacto");
        jTxtDirRep.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtDirRepKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14)
                    .addComponent(jLabel24))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTxtDirRep)
                    .addComponent(jTxtTelefonoRep, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                    .addComponent(jTxtCelularRep)
                    .addComponent(jTxtNombreRep))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jTxtNombreRep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(jTxtTelefonoRep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(jTxtCelularRep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(jTxtDirRep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OBSERVACIONES: ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12))); // NOI18N

        jTxaObs.setColumns(20);
        jTxaObs.setRows(5);
        jScrollPane2.setViewportView(jTxaObs);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
        );

        jBtnLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/tango-clear.png"))); // NOI18N
        jBtnLimpiar.setText("LIMPIAR ENTRADAS");
        jBtnLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnLimpiarActionPerformed(evt);
            }
        });

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel22.setForeground(new java.awt.Color(255, 255, 255));
        jLabel22.setText("Teléfono:");

        jLabel19.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel19.setForeground(new java.awt.Color(255, 255, 255));
        jLabel19.setText("Ciudad");

        jTxtFax.setToolTipText("Fax de la Empresa");
        jTxtFax.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtFaxKeyPressed(evt);
            }
        });

        jTxtMail.setToolTipText("Correo Electronico");
        jTxtMail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtMailKeyPressed(evt);
            }
        });

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("Pais");

        jLabel23.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel23.setForeground(new java.awt.Color(255, 255, 255));
        jLabel23.setText("Nº FAX:");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("Nit");

        jTxtDireccion.setToolTipText("Direccion de la Empresa");
        jTxtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtDireccionKeyPressed(evt);
            }
        });

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel16.setForeground(new java.awt.Color(255, 255, 255));
        jLabel16.setText("Provincia: ");

        jCbxProvincia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCbxProvinciaActionPerformed(evt);
            }
        });
        jCbxProvincia.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jCbxProvinciaKeyPressed(evt);
            }
        });

        jCbxPais.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCbxPaisActionPerformed(evt);
            }
        });
        jCbxPais.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jCbxPaisKeyPressed(evt);
            }
        });

        jTxtTelefonoPr.setToolTipText("Telefono de la Empresa");
        jTxtTelefonoPr.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtTelefonoPrKeyPressed(evt);
            }
        });

        jLblCodigo.setFont(new java.awt.Font("Tahoma", 1, 13));
        jLblCodigo.setForeground(new java.awt.Color(255, 0, 0));

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel17.setForeground(new java.awt.Color(255, 255, 255));
        jLabel17.setText("E - Mail:");

        jLabel21.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel21.setForeground(new java.awt.Color(255, 255, 255));
        jLabel21.setText("Dirección:");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Codigo:");

        jTxtNombrePr.setToolTipText("Nombre de la Empresa");
        jTxtNombrePr.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtNombrePrKeyPressed(evt);
            }
        });

        jTnit.setToolTipText("Nit de la Empresa");
        jTnit.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTnitKeyPressed(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel20.setForeground(new java.awt.Color(255, 255, 255));
        jLabel20.setText("Nombre:");

        jTxtWeb.setToolTipText("Sitio Web");
        jTxtWeb.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTxtWebKeyPressed(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel18.setForeground(new java.awt.Color(255, 255, 255));
        jLabel18.setText("Página WEB:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel23)
                        .addGap(215, 215, 215))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15)
                            .addComponent(jLabel16)
                            .addComponent(jLabel19))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCbxProvincia, 0, 193, Short.MAX_VALUE)
                            .addComponent(jCbxPais, 0, 193, Short.MAX_VALUE)
                            .addComponent(jCBCiudad, 0, 193, Short.MAX_VALUE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18)
                            .addComponent(jLabel17))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTxtMail, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
                            .addComponent(jTxtWeb, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel10)
                            .addComponent(jLabel20)
                            .addComponent(jLabel11)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22))
                        .addGap(8, 8, 8)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLblCodigo, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                            .addComponent(jTxtTelefonoPr, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                            .addComponent(jTxtDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                            .addComponent(jTnit, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                            .addComponent(jTxtNombrePr, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                            .addComponent(jTxtFax, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLblCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTnit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel20)
                    .addComponent(jTxtNombrePr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel21)
                    .addComponent(jTxtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(jTxtTelefonoPr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(jTxtFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtWeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(jTxtMail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jCbxPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(jCbxProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(jCBCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });

        jLabel25.setBackground(new java.awt.Color(255, 0, 0));
        jLabel25.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel25.setForeground(new java.awt.Color(255, 255, 255));
        jLabel25.setText("Contacto");

        javax.swing.GroupLayout jPanelTransparente4Layout = new javax.swing.GroupLayout(jPanelTransparente4);
        jPanelTransparente4.setLayout(jPanelTransparente4Layout);
        jPanelTransparente4Layout.setHorizontalGroup(
            jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jBtnLimpiar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 636, Short.MAX_VALUE)
                    .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                        .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(16, 16, 16))
                            .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                                .addComponent(jLabel25)
                                .addGap(18, 18, 18)))
                        .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
            .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelTransparente4Layout.createSequentialGroup()
                    .addContainerGap(295, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()))
        );
        jPanelTransparente4Layout.setVerticalGroup(
            jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelTransparente4Layout.createSequentialGroup()
                .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelTransparente4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                        .addGap(165, 165, 165)
                        .addComponent(jPanel3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25))
                .addGap(23, 23, 23)
                .addComponent(jBtnLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanelTransparente4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanelTransparente4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(272, Short.MAX_VALUE)))
        );

        jBSalir1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Desktop 2.png"))); // NOI18N
        jBSalir1.setText("SALIR");
        jBSalir1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBSalir1ActionPerformed(evt);
            }
        });

        jBActualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/refresh.png"))); // NOI18N
        jBActualizar.setText("ACTUALIZAR");
        jBActualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBActualizarActionPerformed(evt);
            }
        });

        ListSelectionModel lssms =  jTable1.getSelectionModel();
        lssms.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                try{
                    if(e.getValueIsAdjusting())return;
                    ListSelectionModel lss=(ListSelectionModel )e.getSource();
                    if(lss.isSelectionEmpty()){
                    }else{
                        condicion=true;
                    }
                }catch(Exception z){
                }
            }
        });
        jBModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/edit.png"))); // NOI18N
        jBModificar.setText("MODIFICAR");
        jBModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBModificarActionPerformed(evt);
            }
        });

        /*  ListSelectionModel lssms =  jTable1.getSelectionModel();
        lssms.addListSelectionListener(new ListSelectionListener(){
            public void valueChanged(ListSelectionEvent e){
                try{
                    if(e.getValueIsAdjusting())return;
                    ListSelectionModel lss=(ListSelectionModel )e.getSource();
                    if(lss.isSelectionEmpty()){
                    }else{
                        condicion=true;
                    }
                }catch(Exception z){
                }
            }
        });*/
        jBEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/stop.png"))); // NOI18N
        jBEliminar.setText("ELIMINAR");
        jBEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBEliminarActionPerformed(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Floppy.png"))); // NOI18N
        jButton1.setText("REGISTRAR");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        JBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/search.png"))); // NOI18N
        JBuscar.setText("BUSCAR");
        JBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelTransparente5Layout = new javax.swing.GroupLayout(jPanelTransparente5);
        jPanelTransparente5.setLayout(jPanelTransparente5Layout);
        jPanelTransparente5Layout.setHorizontalGroup(
            jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(JBuscar, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                    .addComponent(jBActualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBSalir1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                    .addComponent(jBEliminar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                    .addComponent(jBModificar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelTransparente5Layout.setVerticalGroup(
            jPanelTransparente5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jBActualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(JBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jBModificar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                .addComponent(jBEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31)
                .addComponent(jBSalir1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanelTransparente3Layout = new javax.swing.GroupLayout(jPanelTransparente3);
        jPanelTransparente3.setLayout(jPanelTransparente3Layout);
        jPanelTransparente3Layout.setHorizontalGroup(
            jPanelTransparente3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTransparente3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTransparente3Layout.createSequentialGroup()
                        .addComponent(jPanelTransparente4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanelTransparente5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 862, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanelTransparente3Layout.setVerticalGroup(
            jPanelTransparente3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransparente3Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(jPanelTransparente3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanelTransparente4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelTransparente5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelTransparente3, javax.swing.GroupLayout.PREFERRED_SIZE, 888, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelTransparente3, javax.swing.GroupLayout.PREFERRED_SIZE, 589, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jMenu1.setText("Operaciones");
        jMenu1.add(jSeparator1);

        jMenuItem8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/exit.png"))); // NOI18N
        jMenuItem8.setText("Salir");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem8);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edicion");

        jMenuItem1.setText("Copiar");
        jMenu2.add(jMenuItem1);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // Salir
        this.dispose();
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jTxtNombreRepKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtNombreRepKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtTelefonoRep.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtNombreRepKeyPressed

    private void jTxtCelularRepKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtCelularRepKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxaObs.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtCelularRepKeyPressed

    private void jBtnLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnLimpiarActionPerformed
        Limpiar_Entradas();
}//GEN-LAST:event_jBtnLimpiarActionPerformed

    private void jTxtFaxKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtFaxKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtWeb.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtFaxKeyPressed

    private void jTxtMailKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtMailKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jCbxPais.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtMailKeyPressed

    private void jTxtDireccionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtDireccionKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtTelefonoPr.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtDireccionKeyPressed

    private void jCbxProvinciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCbxProvinciaActionPerformed
              // Ciudades
          if(jCbxPais.getSelectedIndex()!=0){
            String nombre = ""+jCbxPais.getSelectedItem();
            String nombreprovinia = jCbxProvincia.getSelectedItem()+"";
            Pais ps = Mu.Consultar(nombre);
            
            Provincia pro = ps.getProvincia().get(this.Posicion(nombreprovinia, ps.getProvincia()));

            for(int x=0;x<pro.getCiudad().size();x++){
               Ciudad c =(Ciudad) pro.getCiudad().get(x);
               jCBCiudad.addItem(c.getNombre());
            }

        }

}//GEN-LAST:event_jCbxProvinciaActionPerformed

    private void jCbxProvinciaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jCbxProvinciaKeyPressed

}//GEN-LAST:event_jCbxProvinciaKeyPressed

    private void jCbxPaisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCbxPaisActionPerformed
        // Pais
        jCbxProvincia.removeAllItems();
        jCBCiudad.removeAllItems();
        if(jCbxPais.getSelectedIndex()!=0){
            String nombre = ""+jCbxPais.getSelectedItem();
            Pais ps = Mu.Consultar(nombre);

            for(int x=0; x<ps.getProvincia().size();x++){
                  jCbxProvincia.addItem(ps.getProvincia().get(x).getNombre());

        }

       }
}//GEN-LAST:event_jCbxPaisActionPerformed

    private void jCbxPaisKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jCbxPaisKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jCbxProvincia.requestFocus();        // TODO add your handling code here:
}//GEN-LAST:event_jCbxPaisKeyPressed

    private void jTxtTelefonoPrKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtTelefonoPrKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtFax.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtTelefonoPrKeyPressed

    private void jTxtNombrePrKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtNombrePrKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtDireccion.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtNombrePrKeyPressed

    private void jTnitKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTnitKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtNombrePr.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTnitKeyPressed

    private void jTxtWebKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtWebKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtMail.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtWebKeyPressed

    private void jBSalir1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSalir1ActionPerformed
        // Cerramos esta ventana
        this.dispose();
}//GEN-LAST:event_jBSalir1ActionPerformed

    private void jBActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBActualizarActionPerformed
        // Actualizar ó cancelar
        this.Actualizar();
}//GEN-LAST:event_jBActualizarActionPerformed

    private void jBModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBModificarActionPerformed
        // Modificar un proveedor         
        if(jBModificar.getText().equals("MODIFICAR")){
                if(condicion==true){
                    this.ActivarCampos();
                    prov=Mp.getProveedores().get(jTable1.getSelectedRow());
                    mostrar(prov);
                    jBModificar.setText("GUARDAR");
                    ImageIcon[] img_Btns = new ImageIcon[8];
                    img_Btns[0] = new ImageIcon(getClass().getResource("/Imagenes/Floppy.png"));
                    jBModificar.setIcon(img_Btns[0]);
                    jBActualizar.setText("CANCELAR");
                    JOptionPane.showMessageDialog(null, "Se han activado los campos para su edicion");
                }else{
                    nits = JOptionPane.showInputDialog("Digite nit del proveedor");

                    if(nits!=null){
                        prov = Mp.Consultar(nits);
                        if(prov.getNit().equals("")){
                            JOptionPane.showMessageDialog(null, "Este proveedor no existe");
                        } else {
                            this.mostrar(prov);
                            this.ActivarCampos();
                               jBModificar.setText("GUARDAR");
                                ImageIcon[] img_Btns = new ImageIcon[8];
                                img_Btns[0] = new ImageIcon(getClass().getResource("/Imagenes/Floppy.png"));
                                jBModificar.setIcon(img_Btns[0]);
                                jBActualizar.setText("CANCELAR");
                                JOptionPane.showMessageDialog(null, "Se han activado los campos para su edicion");
                        }

                     }
                }
                vp.add(prov);
        }else{
            
            Proveedor prr = new Proveedor();
            prr.setCodigo(jLblCodigo.getText());
            prr.setNit(jTnit.getText());
            prr.setNombre(jTxtNombrePr.getText());
            prr.setDireccion(jTxtDireccion.getText());
            prr.setTelefono(jTxtTelefonoPr.getText());
            prr.setFax(jTxtFax.getText());
            prr.setWeb(jTxtWeb.getText());
            prr.setEmail(jTxtMail.getText());
            prov = vp.get(0);
            Mp.Modificar(prov.getNit(), prr);
            this.Actualizar();


        }

        this.condicion = false;
        prov=new Proveedor();

}//GEN-LAST:event_jBModificarActionPerformed

    private void jBEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBEliminarActionPerformed
        // Eliminar
        Proveedor pr = new Proveedor();
        if(condicion==true){
            int question = JOptionPane.showConfirmDialog(null,"¿Seguro que desea"
                    + " eliminar este proveedor?","Informacion",JOptionPane.YES_NO_OPTION);
            if(question==0){
                int posicion=this.jTable1.getSelectedRow();
                pr = Mp.getProveedores().get(posicion);
                modeloTabla.removeRow(posicion);
                Mp.Eliminar(pr.getNit());
            }else{
                JOptionPane.showMessageDialog(null, "Peticion ca"
                        + "ncelada","Informacion",JOptionPane.INFORMATION_MESSAGE);
            }

        }else{
                 String nits = JOptionPane.showInputDialog("Digite nit del proveedor");

                    if(nits!=null){
                        pr = Mp.Consultar(nits);
                        if(pr.getNit().equals("")){
                            JOptionPane.showMessageDialog(null, "Este proveedor no existe");
                        } else {

                            int posicion = Mp.Posicion(pr.getNit());
                            modeloTabla.removeRow(posicion);
                            Mp.Eliminar(pr.getNit());

                        }


                 }
        }
        this.condicion = false;
}//GEN-LAST:event_jBEliminarActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        //Registrar

        if(jButton1.getText().equals("GUARDAR")){

            Proveedor pr = new Proveedor();
            pr.setCodigo(jLblCodigo.getText());
            pr.setNit(jTnit.getText());
            pr.setNombre(jTxtNombrePr.getText());
            pr.setDireccion(jTxtDireccion.getText());
            pr.setTelefono(jTxtTelefonoPr.getText());
            pr.setFax(jTxtFax.getText());
            pr.setWeb(jTxtWeb.getText());
            pr.setEmail(jTxtMail.getText());
            pr.setUbicacion(new Ubicacion(jCbxPais.getSelectedItem().toString(), jCbxProvincia.getSelectedItem().toString(), jCBCiudad.getSelectedItem().toString()));
            pr.setContacto(Mc.ConsultarString(this.jComboBox2.getSelectedItem().toString()));
            Mp.Registrar(pr);
          
            this.Actualizar();


        }else{
            this.ActivarCampos();
            this.jComboBox2.setVisible(true);
            this.llenarcombo();
            this.jLabel25.setVisible(true);
            this.jButton1.setText("GUARDAR");
            this.jBActualizar.setText("CANCELAR");
            ImageIcon[] img_Btns = new ImageIcon[8];
            img_Btns[0] = new ImageIcon(getClass().getResource("/Imagenes/stop_alt.png"));
            jBActualizar.setIcon(img_Btns[0]);
            this.Limpiar_Entradas();
            this.jLblCodigo.setText(this.Mp.GenerarCodigo()+"");
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void JBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBuscarActionPerformed
        // Buscar proveedor especificamente
        
        String nit = JOptionPane.showInputDialog("Digite Nit del Proveedor a buscar");
        Proveedor pr = Mp.Consultar(nit);
        if(pr.getNit().equals("")){
            JOptionPane.showMessageDialog(null, "Proveedor no Encontrado");
        }else{
            this.mostrar(pr);
        }
        jBModificar.setEnabled(true);
        estado=true;
}//GEN-LAST:event_JBuscarActionPerformed

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
        // tabla
        int indice = jTable1.getSelectedRow();
        Proveedor pr = Mp.getProveedores().get(indice);
        this.mostrar(pr);
    }//GEN-LAST:event_jTable1MouseClicked

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        // mostrar datos del contacto seleccionado
        Cliente c = Mc.getListacliente().get(jComboBox2.getSelectedIndex());
        jTxtNombreRep.setText(c.getNombre());
        jTxtDirRep.setText(c.getDireccion());
        jTxtTelefonoRep.setText(c.getTelefono());
        jTxtCelularRep.setText(c.getCelular());
        


    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jTxtTelefonoRepKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtTelefonoRepKeyPressed
        if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtCelularRep.requestFocus();// TODO add your handling code here:
}//GEN-LAST:event_jTxtTelefonoRepKeyPressed

    private void jTxtDirRepKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTxtDirRepKeyPressed
         if(evt.getKeyCode()==evt.VK_ENTER)
            jTxtDirRep.requestFocus();// TODO add your handling code here:
    }//GEN-LAST:event_jTxtDirRepKeyPressed

    private void jTxtNombreRepActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTxtNombreRepActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTxtNombreRepActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {

       try {
             javax.swing.UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
             LiquidLookAndFeel.setLiquidDecorations(true, "mac");

}
catch (Exception e) {}

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VistaProveedor().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JBuscar;
    private javax.swing.JButton jBActualizar;
    private javax.swing.JButton jBEliminar;
    private javax.swing.JButton jBModificar;
    private javax.swing.JButton jBSalir1;
    private javax.swing.JButton jBtnLimpiar;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jCBCiudad;
    private javax.swing.JComboBox jCbxPais;
    private javax.swing.JComboBox jCbxProvincia;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLblCodigo;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private Imagenes.JPanelTransparente jPanelTransparente3;
    private Imagenes.JPanelTransparente jPanelTransparente4;
    private Imagenes.JPanelTransparente jPanelTransparente5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTnit;
    private javax.swing.JTextArea jTxaObs;
    private javax.swing.JTextField jTxtCelularRep;
    private javax.swing.JTextField jTxtDirRep;
    private javax.swing.JTextField jTxtDireccion;
    private javax.swing.JTextField jTxtFax;
    private javax.swing.JTextField jTxtMail;
    private javax.swing.JTextField jTxtNombrePr;
    private javax.swing.JTextField jTxtNombreRep;
    private javax.swing.JTextField jTxtTelefonoPr;
    private javax.swing.JTextField jTxtTelefonoRep;
    private javax.swing.JTextField jTxtWeb;
    // End of variables declaration//GEN-END:variables


    

    private void seguro() {

        int salir=JOptionPane.showConfirmDialog(null, "¿Desea Cerrar La vista?","Cerrar",JOptionPane.YES_NO_OPTION);
           if(salir ==1){
              this.dispose();
           }
    }

    public void Limpiar_Entradas(){
    jLblCodigo.setText("");
    jTnit.setText("");
    jTxtNombrePr.setText("");
    jTxtDireccion.setText("");
    jTxtTelefonoPr.setText("");
    jTxtFax.setText("");
    jTxtWeb.setText("");
    jTxtMail.setText("");
    jCbxPais.setSelectedIndex(0);
    jTxtNombreRep.setText("");
    jTxtTelefonoRep.setText("");
    jTxtCelularRep.setText("");
    jTxaObs.setText("");    
    jTnit.requestFocus();
}

 public void ActivarCampos(){

    jTnit.setEditable(true);
    jTxtNombrePr.setEditable(true);
    jTxtDireccion.setEditable(true);
    jTxtTelefonoPr.setEditable(true);
    jTxtFax.setEditable(true);
    jTxtWeb.setEditable(true);
    jTxtMail.setEditable(true);
    jTxaObs.setEditable(true);
}

public void DesactivarCampos(){
    
    jTnit.setEditable(false);
    jTxtNombrePr.setEditable(false);
    jTxtDireccion.setEditable(false);
    jTxtTelefonoPr.setEditable(false);
    jTxtFax.setEditable(false);
    jTxtWeb.setEditable(false);
    jTxtMail.setEditable(false);
    jTxaObs.setEditable(false);
}
    private void mostrar(Proveedor pr) {
        jLblCodigo.setText(pr.getCodigo());
        jTnit.setText(pr.getNit());
        jTxtNombrePr.setText(pr.getNombre());
        jTxtDireccion.setText(pr.getDireccion());
        jTxtTelefonoPr.setText(pr.getTelefono());
        jTxtFax.setText(pr.getFax());
        jTxtWeb.setText(pr.getWeb());
        jTxtMail.setText(pr.getEmail());
    }

    public void Actualizar(){
        this.dispose();
        VistaProveedor vp = new VistaProveedor(Mp, Mc,Mu);
        vp.setLocationRelativeTo(null);
        vp.setVisible(true);
    }


     protected void mostrarMensaje(String mensaje) {
                JOptionPane.showMessageDialog(this, mensaje, "Advertencia",
                                JOptionPane.WARNING_MESSAGE);
        }

     public void llenarcombo(){
         for(int x =0;x<Mc.getListacliente().size();x++){
            this.jComboBox2.addItem(Mc.getListacliente().get(x).getNombre());
        }
     }

         public int Posicion(String nombre,List<Provincia> pro){
             Provincia p;
          Iterator itc=pro.iterator();
          int pos=-1;
          int ind=-1;
         while(itc.hasNext()){
             p = (Provincia)itc.next();
            if(p.getNombre().equals(nombre)){
                ind=ind+1;
                 pos=ind;
            }else{
                ind=ind+1;
            }
         }
          return pos;
    }

    private void tablaprincipal() {
         modeloTabla.addColumn("Codigo");
        modeloTabla.addColumn("NIT");
        modeloTabla.addColumn("nombre");
        modeloTabla.addColumn("direccion");
        modeloTabla.addColumn("tel");
        modeloTabla.addColumn("no. Fax");
        modeloTabla.addColumn("Email");


        for(int x=0;x<this.Mp.getProveedores().size();x++){
            Vector<String> vp=new Vector<String>();
            p = this.Mp.getProveedores().get(x);
            vp.add(p.getCodigo());
            vp.add(""+p.getNit());
            vp.add(p.getNombre());
            vp.add(p.getDireccion());
            vp.add(p.getTelefono());
            vp.add(p.getFax());
            vp.add(p.getEmail());
            modeloTabla.addRow(vp);
        }
    }

    private void MostrarJCBpais() {
            jCbxPais.addItem("---Ver---");
        for(int x=0;x<Mu.getPaises().size();x++){
            jCbxPais.addItem(Mu.getPaises().get(x).getNombre());
        }
    }
}
